﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BL;
using ERP.Membership;

namespace ERP.Account
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
        }

        protected void btnLoginButton_Click(object sender, EventArgs e)
        {
            ERPMembership membership = new ERPMembership();
            var result = membership.Login(UserName.Text, Password.Text);

            if (result.Item1 == ERPMembership.LoginStatus.Success)
            {
                Response.Redirect("~/");
            }
            else
            {
                FailureText.Text = "Login failed";
            }
        }
    }
}
